home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / cfengine-1.5.3 / src / repository.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-09  |  2.9 KB  |  126 lines

  1. /* cfengine for GNU
  2.  
  3.         Copyright (C) 1995
  4.         Free Software Foundation, Inc.
  5.  
  6.    This file is part of GNU cfengine - written and maintained 
  7.    by Mark Burgess, Dept of Computing and Engineering, Oslo College,
  8.    Dept. of Theoretical physics, University of Oslo
  9.  
  10.    This program is free software; you can redistribute it and/or modify it
  11.    under the terms of the GNU General Public License as published by the
  12.    Free Software Foundation; either version 2, or (at your option) any
  13.    later version.
  14.  
  15.    This program is distributed in the hope that it will be useful,
  16.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.    GNU General Public License for more details.
  19.  
  20.   You should have received a copy of the GNU General Public License
  21.   along with this program; if not, write to the Free Software
  22.   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
  23.  
  24. */
  25.  
  26.  
  27. /*********************************************************************/
  28. /*                                                                   */
  29. /*  Repository handler                                               */
  30. /*                                                                   */
  31. /*********************************************************************/
  32.  
  33. #include "cf.defs.h"
  34. #include "cf.extern.h"
  35. #include "../pub/global.h"
  36. #include "../pub/md5.h"
  37.  
  38. /*********************************************************************/
  39.  
  40. Repository(file)
  41.  
  42. char *file;
  43.  
  44. { char buffer[bufsize];
  45.   char node[maxlinksize];
  46.   struct stat sstat, dstat;
  47.   char *sp;
  48.   struct Image dummy;
  49.   short imagecopy;
  50.  
  51. if (!IMAGEBACKUP)
  52.    {
  53.    return true;
  54.    }
  55.  
  56. if (IsItemIn(VREPOSLIST,file))
  57.    {
  58.    return true;
  59.    }
  60.  
  61. PrependItem(&VREPOSLIST,file,NULL);
  62.  
  63. if (VREPOSITORY[0] == '\0' || HOMECOPY)
  64.    {
  65.    return false;
  66.    }
  67.  
  68. Debug2("Repository(%s)\n",file);
  69.  
  70. strcpy (node,file);
  71.  
  72. buffer[0] = '\0';
  73.  
  74. for (sp = node; *sp != '\0'; sp++)
  75.    {
  76.    if (*sp == '/')
  77.       {
  78.       *sp = REPOSCHAR;
  79.       }
  80.    }
  81.  
  82. strcpy(buffer,VREPOSITORY);
  83. AddSlash(buffer);
  84.  
  85. if (BufferOverflow(buffer,node))
  86.    {
  87.    printf("culprit: Repository()\n");
  88.    return false;
  89.    }
  90.  
  91. strcat(buffer,node);
  92.  
  93. MakeDirectoriesFor(buffer);
  94.  
  95. if (stat(file,&sstat) == -1)
  96.    {
  97.    Debug2("Repository file %s not there\n",file);
  98.    return true;
  99.    }
  100.  
  101. stat(buffer,&dstat);
  102.  
  103. imagecopy = IMAGEBACKUP;   /* without this there would be loop between this */
  104. IMAGEBACKUP = false;       /* and Repository */
  105.  
  106. dummy.server = "localhost";
  107. dummy.inode_cache = NULL;
  108. dummy.cache = NULL;
  109. dummy.stealth = 'f';
  110. dummy.secure = false; 
  111.  
  112. CheckForHoles(&sstat,&dummy);
  113.  
  114. if (CopyReg(file,buffer,sstat,dstat,&dummy))
  115.    {
  116.    IMAGEBACKUP = imagecopy;
  117.    return true;
  118.    }
  119. else
  120.    {
  121.    IMAGEBACKUP = imagecopy;
  122.    return false;
  123.    }
  124. }
  125.  
  126.